<template>
  <div class="content">
    <div class="detail">
      <div class="head"><span>登录地点</span></div>
      <div class="info">
        <ul>
          <li v-for="(item,index) in info.list" :key="index">
            <div class="address flex-start">
              <div class="pic">
                <img src="@/assets/address.png" alt="" />
              </div>
              <div class="didian">{{item.loginAddress}}</div>
            </div>
            <div class="time">{{ item.loginTime?setLocalTime(item.loginTime):item.loginTime }}</div>
            <div class="ip">
              IP：{{item.loginIp}}
            </div>
          </li>

        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // id: this.$route.params.id
    }
  },
  computed: {
    id () {
      return Number(sessionStorage.getItem('id'))
    },
    info () {
      // return this.$store.state.userManage.tableData.filter(item => item.id === this.id)[0]
      return this.$store.state.userManage.tableData
    }
  },
  created () {
    const phone = sessionStorage.getItem('id')
    const page = 1
    const size = 10
    this.$store.dispatch('userManage/getAddressData', { page, size, phone }).then(res => {
      // console.log(res.data)
    }).catch(err => {
      this.$message({
        type: 'error',
        message: err,
        duration: 1000
      })
    })
  },
  methods: {
    setLocalTime (time) {
      return this.$moment(+new Date(time)).format('YYYY-MM-DD HH:mm:ss')
    }
  }
}
</script>

<style lang="scss" scoped>
.content {
  .detail {
    min-height: 932px;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 8px;
    // margin-top: 26px;
    padding: 0 24px;
    position: relative;
  }

  .head {
    width: 100%;
    height: 78px;
    border-bottom: 1px solid #e6e9f0;
    position: relative;
    font-size: 16px;
    font-weight: 500;
    color: #1b1f35;
    span {
      position: absolute;
      bottom: 20px;
    }
  }
  .info {
    margin-top: 40px;
    margin-left: 26px;
    li {
      padding: 9px 7px;
      margin-bottom: 20px;
      .pic {
        width: 14px;
        height: 14px;
        margin-right: 8px;
        img {
          width: 100%;
          vertical-align: top;
        }
      }
    }
  }
}
</style>
